<html>
<head><meta charset="utf-8"><title>Setting `llvm-config` on NixOS · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html">Setting `llvm-config` on NixOS</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="202780020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202780020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202780020">(Jul 03 2020 at 08:36)</a>:</h4>
<p>Y-problem: can I override values from <code>config.toml</code> with env vars? Specifically, I'd like to override <code>llvm-config</code>.</p>
<p>X-problem: I am on NixOS, and I want to use system llvm for buliding rust. At the moment, I have <code>llvm-config = "/nix/store/0ckky0m4yv82wm85vxac27qbzcsxz2z7-llvm-9.0.1/bin/llvm-config"</code> in my <code>config.toml</code>, but that obviously breaks after update, if llvm dir changes hash. Can I write some kind of <code>shell.nix</code> expression that makes this work?</p>



<a name="202780505"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202780505" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202780505">(Jul 03 2020 at 08:42)</a>:</h4>
<p>Does setting <code>llvm-config = "llvm-config"</code> work? It should then search it in <code>PATH</code>.</p>



<a name="202780859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202780859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202780859">(Jul 03 2020 at 08:46)</a>:</h4>
<p>Nope, it looks it up in cwd :(</p>



<a name="202780900"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202780900" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202780900">(Jul 03 2020 at 08:47)</a>:</h4>
<p><code>failed to execute command: "/home/matklad/projects/rust/llvm-config" "--bindir"</code></p>
<p>Though I guess I can put a shell script there <span aria-label="smiling devil" class="emoji emoji-1f608" role="img" title="smiling devil">:smiling_devil:</span></p>



<a name="202781000"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202781000" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202781000">(Jul 03 2020 at 08:48)</a>:</h4>
<div class="codehilite"><pre><span></span><code>10:48:27|~/projects/rust|ship-rust-analyzer⚡?
λ bat -p llvm-config
#!/bin/sh
llvm-config &quot;$@&quot;
</code></pre></div>


<p>works! Thanks <span class="user-mention" data-user-id="133247">@bjorn3</span> !</p>



<a name="202785286"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202785286" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> davidtwco <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202785286">(Jul 03 2020 at 09:41)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I had a patch land recently so that bootstrap can get the <code>config.toml</code> from an environment variable - I use it so that I can define my <code>config.toml</code> in my Nix shell - e.g. <a href="https://github.com/davidtwco/veritas/blob/master/nix/shells/rustc.nix#L220">my shell</a>. Might help depending what your workflow is.</p>



<a name="202791681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202791681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202791681">(Jul 03 2020 at 11:02)</a>:</h4>
<p>Nice <span aria-label="heart eyes" class="emoji emoji-1f60d" role="img" title="heart eyes">:heart_eyes:</span>! I'll switch to your shell.nix next time mine is broken :)</p>



<a name="202822957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202822957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202822957">(Jul 03 2020 at 17:06)</a>:</h4>
<p><span class="user-mention" data-user-id="133169">@matklad</span> I'm pretty you're not supposed to use <code>config.toml</code> for automated builds. that's why we still have <code>./configure &amp;&amp; make</code></p>



<a name="202823039"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202823039" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202823039">(Jul 03 2020 at 17:07)</a>:</h4>
<p>on top of exposing most of the options (like <code>llvm-config</code>, although you probably want the LLVM root option so you can pass the LLVM derivation to it directly without <code>/bin/llvm-config</code> added to it), you also have <code>--set</code>, IIRC, so you can arbitrary customize the <code>config.toml</code></p>



<a name="202823109"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202823109" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202823109">(Jul 03 2020 at 17:08)</a>:</h4>
<p>oh wait you're doing this for local dev builds, sorry</p>



<a name="202823142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/Setting%20%60llvm-config%60%20on%20NixOS/near/202823142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/Setting.20.60llvm-config.60.20on.20NixOS.html#202823142">(Jul 03 2020 at 17:08)</a>:</h4>
<p>(you could still craft a <code>./configure</code> command with everything you need, I guess :P)</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>